using System;
using System.Collections.Generic;
using System.Text;

namespace DiggTools
{
    /// <summary>
    /// Thr SortFactory houses all of the sort methods used in the DiggTools namespace.
    /// </summary>
    public static class SortFactory
    {
        /// <summary>
        /// Sorts each story depending on the number of diggs each has.
        /// </summary>
        /// <param name="x">the first story</param>
        /// <param name="y">the second story</param>
        /// <returns>an inegeger representing which is greater. (1: y > x, -1: x > 1, 0: x == y)</returns>
        public static int SortByDiggs(Story x, Story y)
        {
            if ( x.diggs > y.diggs )
            {
                return -1;
            }
            else if (x.diggs < y.diggs)
            {
                return 1;
            }
            else
            {
                return 0;
            }
        }

        /// <summary>
        /// Sorts each story depending on the number of comments each has.
        /// </summary>
        /// <param name="x">the first story</param>
        /// <param name="y">the second story</param>
        /// <returns>an inegeger representing which is greater. (1: y > x, -1: x > 1, 0: x == y)</returns>
        public static int SortByComments(Story x, Story y)
        {
            if (x.comments > y.comments)
            {
                return -1;
            }
            else if (x.comments < y.comments)
            {
                return 1;
            }
            else
            {
                return 0;
            }
        }

    }
}
